﻿using System;
using System.Reflection;
using FluentNHibernate.Conventions;
using FluentNHibernate.Conventions.Inspections;
using FluentNHibernate.Conventions.Instances;
using FluentNHibernate.Mapping;
using FluentNHibernate.Conventions.AcceptanceCriteria;

namespace br.com.portocs.unidaacademico.repositorio.conventions
{
    public class EnumMappingConvention : IUserTypeConvention
    {        
        #region IConventionAcceptance<IPropertyInspector> Members

        public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
        {
            criteria.Expect(x => x.Property.PropertyType.IsEnum);
        }

        #endregion

        #region IConvention<IPropertyInspector,IPropertyInstance> Members

        public void Apply(IPropertyInstance instance)
        {
            instance.CustomType(instance.Property.PropertyType);
        }

        #endregion
    } 

}
